define(['jquery', 'table'], function ($, Table) {
	var c = {
		test: function () {
			console.log('Hello World!');
		},
		// var func = throttle(function(){}, 1000);
		throttle(func, delay) {
			let timer = null;
			return function () {
				const context = this;
				const args = arguments;
				if (!timer) {
					timer = setTimeout(function () {
						func.apply(context, args);
						timer = null;
					}, delay);
				}
			};
		},
		debounce(func, wait) {
			let timeout;
			return function executedFunction(...args) {
				const later = () => {
					clearTimeout(timeout);
					func(...args);
				};
				clearTimeout(timeout);
				timeout = setTimeout(later, wait);
			};
		},
		xc_tab_processfield(fieldname) {
			var xc_tabid = $("#xc_tabid", window.parent.document).val();
			$("#c-" + fieldname).val(xc_tabid); //xcframework
			$("#c-" + fieldname).attr("disabled", "true");
			$("#c-" + fieldname).after("<input type='hidden' name='row[" + fieldname + "]' value='" + xc_tabid + "'>");
		},
		openWindow(url) {
			var that = this;
			var form = document.createElement('form');
			form.action = url;
			form.target = '_blank';
			document.body.appendChild(form);
			form.submit();
		},
	};
	return c;
});